//
//  SiftDetailTableViewCell.m
//  ZYZB
//
//  Created by ENERGY on 2018/7/3.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "SiftDetailTableViewCell.h"

@interface SiftDetailTableViewCell()
@property (nonatomic, strong)UIImageView * iconImg;
@property (nonatomic, strong)UILabel * titleLab;
@property (nonatomic, strong)UIImageView * arrowImg;
@end

@implementation SiftDetailTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        __weak typeof (self)weakSelf = self;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor whiteColor];
        UIView * lineView = [[UIView alloc] init];
        lineView.backgroundColor = getColor(borderColor);
        [self.contentView addSubview:lineView];
        [self.contentView addSubview:self.titleLab];
        [self.contentView addSubview:self.iconImg];
        [self.contentView addSubview:self.arrowImg];
        [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView.mas_left).mas_offset(18/WIDTH_6_SCALE);
            make.width.mas_offset(22/WIDTH_6_SCALE);
            make.height.mas_offset(22/WIDTH_6_SCALE);
            make.centerY.equalTo(weakSelf.titleLab);
        }];
        [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.iconImg.mas_right).mas_offset(6/WIDTH_6_SCALE);
            make.top.equalTo(weakSelf.contentView.mas_top);
            make.bottom.equalTo(lineView.mas_top);
        }];
        [self.arrowImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(weakSelf.contentView.mas_right).mas_offset(-18/WIDTH_6_SCALE);
            make.centerY.equalTo(weakSelf.titleLab.mas_centerY);
            make.height.mas_offset(13/WIDTH_6_SCALE);
            make.width.mas_offset(8/WIDTH_6_SCALE);
        }];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView.mas_left).mas_offset(16/WIDTH_6_SCALE);
            make.right.equalTo(weakSelf.contentView.mas_right).mas_offset(-16/WIDTH_6_SCALE);
            make.height.mas_offset(1/WIDTH_6_SCALE);
            make.bottom.equalTo(weakSelf.contentView.mas_bottom).mas_offset(-1/WIDTH_6_SCALE);
        }];
    }return self;
}
#pragma mark - init
- (UIImageView *)iconImg{
    if (!_iconImg) {
        _iconImg = [[UIImageView alloc] init];
//        _iconImg.backgroundColor = [UIColor redColor];
        
    }return _iconImg;
}
- (UILabel *)titleLab{
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.text = @"产品介绍";
        _titleLab.font = DEF_FontSize_12;
        _titleLab.textColor = [UIColor blackColor];
        _titleLab.textAlignment = NSTextAlignmentLeft;
        
    }return _titleLab;
}
- (UIImageView *)arrowImg{
    if (!_arrowImg) {
        _arrowImg = [[UIImageView alloc] init];
//        _arrowImg.backgroundColor = [UIColor orangeColor];
        _arrowImg.image = [UIImage imageNamed:@"in"];
    }return _arrowImg;
}

- (void)setModel:(NSDictionary *)model{
    _model = model;
    self.titleLab.text = model[@"title"];
    self.iconImg.image = [UIImage imageNamed:model[@"img"]];
}
@end
